package dq.study.minimvc.handler;


import dq.study.minimvc.HandlerAdapter;
import dq.study.minimvc.reflect.HandlerMethod;;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class AbstractHandlerMethodAdapter implements HandlerAdapter {

    public AbstractHandlerMethodAdapter() {
    }

    @Override
    public boolean supports(Object handler) {
        return supportsInternal(handler);
    }
    protected abstract boolean supportsInternal(Object handler);

    @Override
    public Object handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        return handleInternal(request, response, (HandlerMethod)handler);
    }

    @Override
    public long getLastModified(HttpServletRequest request, Object handler) {
        return 0;
    }



    protected abstract Object handleInternal(HttpServletRequest request,
                                                   HttpServletResponse response, HandlerMethod handlerMethod) throws Exception;
}
